<?php namespace Siyuanliu\Filmcms;

use Backend;
use System\Classes\PluginBase;

/**
 * filmcms Plugin Information File
 */
class Plugin extends PluginBase
{
    /**
     * Returns information about this plugin.
     *
     * @return array
     */
    public function pluginDetails()
    {
        return [
            'name'        => 'siyuanliu.filmcms::lang.plugin.name',
            'description' => 'siyuanliu.filmcms::lang.plugin.description',
            'author'      => 'siyuanliu.filmcms::lang.plugin.author',
            'icon'        => 'siyuanliu.filmcms::lang.plugin.icon'
        ];
    }

    /**
     * Register method, called when the plugin is first registered.
     *
     * @return void
     */
    public function register()
    {
      // register common.php
      require_once('common/common.php');
    }

    /**
     * Boot method, called right before the request route.
     *
     * @return array
     */
    public function boot()
    {

    }

    /**
     * Registers any front-end components implemented in this plugin.
     *
     * @return array
     */
    public function registerComponents()
    {
      //  return []; // Remove this line to activate

        return [
            'Siyuanliu\Filmcms\Components\MyComponent' => 'myComponent',
        ];
    }

    /**
     * Registers any back-end permissions used by this plugin.
     *
     * @return array
     */
    public function registerPermissions()
    {
      //  return []; // Remove this line to activate

        return [
            'siyuanliu.filmcms.some_permission' => [
                'tab' => 'filmcms',
                'label' => 'Some permission'
            ],
        ];
    }

    /**
     * Registers back-end navigation items for this plugin.
     *
     * @return array
     */
    public function registerNavigation()
    {
        //return []; // Remove this line to activate

        return [
            'filmcms' => [
                'label'       => 'siyuanliu.filmcms::lang.cms.menu_label',
                'url'         => Backend::url('siyuanliu/filmcms/films'),
                'icon'        => 'icon-leaf',
                'permissions' => ['siyuanliu.filmcms.*'],
                'order'       => 500,
                'sideMenu' => [
                    'new_post' => [
                        'label'       => 'siyuanliu.filmcms::lang.cms.sub_nav.new_post.name',
                        'icon'        => 'icon-plus',
                        'url'         => Backend::url('siyuanliu/filmcms/films/create'),
                        'permissions' => ['siyuanliu.filmcms.*']
                    ],
                    'posts' => [
                        'label'       => 'siyuanliu.filmcms::lang.cms.sub_nav.posts.name',
                        'icon'        => 'icon-copy',
                        'url'         => Backend::url('siyuanliu/filmcms/films/index'),
                        'permissions' => ['siyuanliu.filmcms.*']
                    ],
                    'categories' => [
                        'label'       => 'siyuanliu.filmcms::lang.cms.sub_nav.categories.name',
                        'icon'        => 'icon-list-ul',
                        'url'         => Backend::url('siyuanliu/filmcms/categories/index'),
                        'permissions' => ['siyuanliu.filmcms.*']
                    ],
                    'gather' => [
                        'label'       => 'siyuanliu.filmcms::lang.cms.sub_nav.gather.name',
                        'icon'        => 'icon-list-ul',
                        'url'         => Backend::url('siyuanliu/filmcms/films/gather'),
                        'permissions' => ['siyuanliu.filmcms.*']
                    ],
                ]
            ],
        ];
    }

    // register widgets form
    public function registerFormWidgets()
    {
        return [
            'Siyuanliu\Filmcms\FormWidgets\CategorySelector' => 'categoryselector',
            'Siyuanliu\Filmcms\FormWidgets\gatherTitle' => 'gathertitle',
        ];
    }
}
